import { BasePath } from "../apiClass"
import { IResult } from "../../plugins/Interfaces"

const loginInUrl: string = process.env.VUE_APP_LOGIN_IN || ''
const loginOutUrl: string = process.env.VUE_APP_LOGIN_OUT || ''
const loginInfoUrl: string = process.env.VUE_APP_LOGIN_INFO || ''
const imgVerifyCodeUrl: string = process.env.VUE_APP_LOGIN_IMG_VERIFY_CODE || ''
const systemAuthUrl: string = process.env.VUE_APP_LOGIN_SYSTEM_AUTH || ''

const system = process.env.VUE_APP_SYSTEM || ''


export interface ILoginInfo{
	username: string,
	password: string,
	uniqueKey: string,
	verifyCode: string,
}


export class LoginApi extends BasePath {
  private baseUrl: string = this.path;
  async in(login:ILoginInfo): Promise<IResult> {
    const resp = await this.client.post(this.baseUrl + loginInUrl, login)
    return resp.data
  }
  async out(): Promise<IResult> {
    const resp = await this.client.get(this.baseUrl + loginOutUrl)
    return resp.data
  }
  async info(): Promise<IResult> {
    const resp = await this.client.get(this.baseUrl + loginInfoUrl)
    return resp.data
  }
  async verifyCode(): Promise<IResult> {
    const resp = await this.client.get(this.baseUrl + imgVerifyCodeUrl)
    return resp.data
  }
  async systemAuth(): Promise<IResult> {
    const resp = await this.client.post(this.baseUrl + systemAuthUrl, {'system': system})
    return resp.data
  }
}